package com.syzsn.sk8.repository;

import com.syzsn.sk8.entity.SySK8WorldCupDivision;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface SySK8WorldCupDivisionRepository extends JpaRepository<SySK8WorldCupDivision, String> {

    @Query(value = "select * from SY_SK8_WORLDCUP_DIVISION where WC_ID=?1 and DIVISION is not null order by DIVISION", nativeQuery = true)
    List<SySK8WorldCupDivision> findListByWcId(Integer wcId);

    @Query(value = "select * from SY_SK8_WORLDCUP_DIVISION where WC_ID=?1 and DIVISION=?2 order by DIVISION", nativeQuery = true)
    List<SySK8WorldCupDivision> findListByWcIdAndDivision(Integer wcId, Integer division);

    @Query(value = "select * from SY_SK8_WORLDCUP_DIVISION where WC_ID=?1 order by SK8_TYPE", nativeQuery = true)
    List<SySK8WorldCupDivision> findListByWcIdForNoDivision(Integer wcId);

    @Query(value = "select * from SY_SK8_WORLDCUP_DIVISION where WC_ID=?1 and COUNTRY_ID=?2", nativeQuery = true)
    SySK8WorldCupDivision findOneByWcIdAndCountryId(Integer wcId, String countryId);
}
